package com.yx.edu.Interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyInterceptor2 implements HandlerInterceptor {

    /**
     * 在handler方法业务逻辑执行之前执行
     *
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        System.out.println("preHandle2222222 拦截器执行了========================");
        //返回false表示，请求被拦截了，不会执行handler方法以及之后的逻辑，true表示放行
        return true;
    }

    /**
     * 在handler方法业务逻辑执行之后，尚未跳转页面时执行
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView 封装了视图和诗句，可以在这对数据和视图信息做一个统一的修改
     * @throws Exception
     */
    @Override
    public void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("postHandle2222222 拦截器执行了========================");
    }

    /**
     * 页面已经跳转渲染完毕之后执行
     *
     * @param request
     * @param response
     * @param handler
     * @param ex
     * @throws Exception
     */
    @Override
    public void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("afterCompletion2222222 拦截器执行了========================");
    }
}
